package com.nekrashevych.util;

import java.io.File;

import org.apache.commons.io.filefilter.AbstractFileFilter;

public class MathingNameFileFilter extends AbstractFileFilter {
    private String name;

    public MathingNameFileFilter(String name) {
        this.name = name;
    }

    @Override
    public boolean accept(File file) {
        return file.getName().contains(name);
    }

    @Override
    public String toString() {
        StringBuilder buffer = new StringBuilder();
        buffer.append(super.toString());
        buffer.append("(");
        buffer.append(name);
        buffer.append(")");
        return buffer.toString();
    }
}
